﻿Imports System.Data.SqlClient

Public Class clsStatusCargaDiesel
    Private mintIdTanque As Integer
    Private mintIdAutobus As Integer
    Public Property IdTanque() As Integer
        Get
            Return mintIdTanque
        End Get
        Set(ByVal value As Integer)
            mintIdTanque = value
        End Set
    End Property
    Public Property IdAutobus() As Integer
        Get
            Return mintIdAutobus
        End Get
        Set(ByVal value As Integer)
            mintIdAutobus = value
        End Set
    End Property
    Public Sub New()
        mintIdAutobus = 0
        mintIdTanque = 0
    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into StatusCargaDiesel (" & _
                            "IdTanque," & _
                            "IdAutobus) " & _
                            "VALUES (" & _
                            "@IdTanque," & _
                            "@IdAutobus) "


        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdTanque", mintIdTanque)
        Command.Parameters.AddWithValue("IdAutobus", mintIdAutobus)
        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el status", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
